'''
Created on Apr 27, 2012
TC ID: Ecom_5028
Desc: Kiem thu chuc nang xoa mot thong bao
@author: lavang
'''
import unittest
from HTMLTestRunner import HTMLTestRunner
import time
from Functions.globalFunc import preCondition, readData, endCondition
from Functions.loginPageFunc import login
from Functions.announcementFunc import clickOnGoToAnnouncement,\
    deleteAnnouncement, isAnnouncementDelete

username=readData("username")
password=readData("password")
tm_announcementName=readData("announcementName",index=2)
class Ecom_5028(unittest.TestCase):

    def setUp(self):
        preCondition(self)

    def test_Ecom_5028(self):
        print "Buoc 1: Dang nhap website"
        login(self,username,password)
        
        print "Buoc 2: Click 'Go to announcement page' "
        clickOnGoToAnnouncement(self)
        
        print "Buoc 3: Xoa thong bao"
        deleteAnnouncement(self,tm_announcementName)
        
        print "Buoc 4: Xac nhan xoa thong bao thanh cong"
        self.assertFalse(isAnnouncementDelete(self,tm_announcementName), "Failed!")
        print "Passed! Thong bao duoc xoa thanh cong"
    
    def tearDown(self):
        endCondition(self)

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    testSuite = unittest.TestSuite()
    suite = unittest.TestLoader().loadTestsFromTestCase(Ecom_5028)
    dateTime = time.strftime('%Y%m%d_%H_%M_%S')
    buf = file("../../Report/TestResults" + "_" + dateTime + ".html",'wb')
    runner = HTMLTestRunner(
                    stream=buf,
                    title='Test Results',
                    description='Kiem thu chuc nang xoa mot thong bao'
                    )
    runner.run(suite)